from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
import time

testCase = "DBshop011-管理商品添加商品流程"
#进入后台，商品管理，管理商品
firefox=openBrowser(url)
firefox.get(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'商品管理','管理商品')
# 点击添加商品，输入商品名称、本店加个、商品类型
firefox.find_element_by_partial_link_text("添加商品").click()
firefox.find_element_by_id('goods_name').send_keys("苹果XR")
firefox.find_element_by_id('goods_shop_price').send_keys("7999")
firefox.find_element_by_xpath("//select[@id='goods_type']/option[3]").click()
firefox.find_element_by_xpath("(//button[@class='btn btn-small btn-primary'])[1]").click()
# 断言：页面有商品名称即添加成功
try:
    firefox.find_element_by_xpath("//td[contains(.,'苹果XR')]")
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()